Add-Type -AssemblyName System.Drawing

# Load the PNG image
$pngPath = "SmsReceiverApp\icon.png"
$icoPath = "SmsReceiverApp\icon.ico"

# Load the image
$img = [System.Drawing.Image]::FromFile($pngPath)

# Create a bitmap from the image
$bitmap = New-Object System.Drawing.Bitmap $img

# Get the icon handle
$iconHandle = $bitmap.GetHicon()

# Create an icon from the handle
$icon = [System.Drawing.Icon]::FromHandle($iconHandle)

# Save the icon to file
$fileStream = [System.IO.File]::Create($icoPath)
$icon.Save($fileStream)
$fileStream.Close()

# Clean up
$img.Dispose()
$bitmap.Dispose()
$icon.Dispose()

Write-Host "Icon converted successfully to $icoPath"
